export function formatDate(time, seg = '-') {

    if (!time) {
        return;
    }
    let datetime = new Date(time);

    let year = datetime.getFullYear();
    let month = datetime.getMonth() + 1;
    month = addZero(month);
    let day = datetime.getDate();
    day = addZero(day);
    let hour = datetime.getHours();
    hour = addZero(hour);
    let min = datetime.getMinutes();
    min = addZero(min);
    let sec = datetime.getSeconds();
    sec = addZero(sec);
    return year + seg + month + seg + day + ' ' + hour + ':' + min + ':' + sec;
}

function addZero(num) {
    return num > 9 ? num : '0' + num;
}